package model.eval;

import enums.ExtensionEnum;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * @author Jose Martin Rozanec;
 */
public class PolisylogismData implements Serializable {
    private List<SylogismData> sylogismList;
    private int current;

    public PolisylogismData() {
        sylogismList = new ArrayList<SylogismData>();
        current = 0;
    }

    public List<SylogismData> getSylogismList() {
        return sylogismList;
    }

    public void addAscendente(SylogismData data) {
        System.out.println("" + data.getPremisaMayorExtension());
        sylogismList.add(0, data);
        current = 0;
    }

    public void addDescendente(SylogismData data) {
        sylogismList.add(data);
        current = sylogismList.size() - 1;
    }

    public SylogismData next() {
        current++;
        if (current > sylogismList.size() - 1) {
            current = 0;
        }
        return sylogismList.get(current);
    }

    public SylogismData previous() {
        current--;
        if (current < 0) {
            current = sylogismList.size() - 1;
        }
        return sylogismList.get(current);
    }

    public ExtensionEnum getAscendenteExtension() {
        return sylogismList.get(0).getPremisaMayorExtension();
    }

    public ExtensionEnum getDescendenteExtension() {
        return sylogismList.get(sylogismList.size() - 1).getConclusionExtension();
    }

    public SylogismData getCurrent() {
        return sylogismList.get(current);
    }

    public int getCurrentNumber() {
        return current + 1;
    }

    public int getTotalSylogisms() {
        return sylogismList.size();
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        for (int j = 0; j < sylogismList.size(); j++) {
            buffer.append(sylogismList.get(j).toString() + "\n");
        }
        return buffer.toString();
    }
}
